﻿using Mes.Domain.BoundedContext.EntityBase;

namespace Mes.Domain.BoundedContext.Entities.Quality
{
    /// <summary>
    /// 采样计划频率表
    /// </summary>
    public class SampleFreq : NoIdEntityBase
    {
        /// <summary>
        /// 采样计划频率名称
        /// </summary>
        public string Freq_Name { get; set; } = string.Empty;

        /// <summary>
        /// 采样计划频率描述
        /// </summary>
        public string? Freq_Desc { get; set; }

        /// <summary>
        /// 采样计划频率类型
        /// 0 = shift, 1 (default) = calendar time, 2 = run time, 3 = production, 4 and up = data change event (see DB documentation for details)
        /// </summary>
        public int Freq_Type { get; set; } = 1;

        /// <summary>
        /// 间隔
        /// If freq_type = 0, 1, or 2, the amount of time between samples(integers only).  If freq_type = 3, the amount of production between samples.  In either case, the meaning of amount is specified in the interval_unit field
        /// </summary>
        public float? Interval { get; set; }

        /// <summary>
        /// 间隔单位
        /// </summary>
        public int? Interval_Unit { get; set; }

        /// <summary>
        /// 生产重设选项
        /// Used only if freq_type = 3.  What causes the count of production between samples to be reset.  0 = nothing (no reset ever), 1 = job changes on job_exec (disallowed if interval_unit = 2), 2 = main item produced changes, 3 = shift changes on entity, 4 = entity utilization changes from runtime or downtime to idle timen
        /// </summary>
        public int? Prod_Reset_Option { get; set; }

        /// <summary>
        /// 偏差开始
        /// Used only if freq_type = 0. Offset from the start of the shift
        /// </summary>
        public int? Offset_Start { get; set; }

        /// <summary>
        /// 偏差开始单位
        /// Used only if freq_type = 0. Offset from the start of the shift
        /// </summary>
        public int? Offset_Start_Unit { get; set; }

        /// <summary>
        /// 偏差结束
        /// Used only if freq_type = 0.  Offset from the end of the shift
        /// </summary>
        public int? Offset_End { get; set; }

        /// <summary>
        /// 偏差结束单位
        /// </summary>
        public int? Offset_End_Unit { get; set; }

        /// <summary>
        /// 每班次的样本
        /// Used only if freq_type = 0. Number of times to ready an event between the offsets from the ends of a shift
        /// </summary>
        public int? Samples_Per_Shift { get; set; }

        /// <summary>
        /// 样本量乘数，默认为1
        /// Sample size multiplier. Minimum value = 1 (also the default)
        /// </summary>
        public int Multiplier { get; set; } = 1;

        /// <summary>
        /// 是否启用
        /// Is this sample plan frequency to be used at runtime
        /// </summary>
        public bool Enabled { get; set; } = true;

        /// <summary>
        /// 采样过期时间
        /// The amount of time to wait for the sample to be pulled before changing its status to READY WARNING; default = Null(no expiration)
        /// </summary>
        public int? Expiry_Time { get; set; }

        /// <summary>
        /// 采样过期单位
        /// </summary>
        public int? Expiry_Unit { get; set; }

        /// <summary>
        /// 采样警告时间，默认为5
        /// The amount of time to wait for a sample to be pulled before changing its status to READY WARNING; default = 5.  Null = no warning
        /// </summary>
        public int? Warning_Time { get; set; } = 5;

        /// <summary>
        /// 采样警告单位The units of warning_time; 1 = minutes (default), 2 = hours, 3 = days
        /// </summary>
        public int Warning_Unit { get; set; } = 1;

        /// <summary>
        /// 备用字段1
        /// </summary>
        public string? Spare1 { get; set; }

        /// <summary>
        /// 备用字段2
        /// </summary>
        public string? Spare2 { get; set; }

        /// <summary>
        /// 备用字段3
        /// </summary>
        public string? Spare3 { get; set; }

        /// <summary>
        /// 备用字段4
        /// </summary>
        public string? Spare4 { get; set; }

        /// <summary>
        /// 最新更新备注
        /// </summary>
        public string? Last_Edit_Comment { get; set; }

        /// <summary>
        /// 最新更新用户
        /// </summary>
        public string Last_Edit_By { get; set; } = string.Empty;

        /// <summary>
        /// 最新更新时间
        /// </summary>
        public DateTime Last_Edit_At { get; set; } = DateTime.Now;

        /// <summary>
        /// 主键
        /// </summary>
        public int Freq_Id { get; set; }
    }
}
